function getURLParam(strParamName){
    var strReturn = "";
    var strHref = window.location.href;
    if ( strHref.indexOf("?") > -1 ){
        var strQueryString = strHref.substr(strHref.indexOf("?")).toLowerCase();
        var aQueryString = strQueryString.split("&");
        for ( var iParam = 0; iParam < aQueryString.length; iParam++ ){
            if (aQueryString[iParam].indexOf(strParamName.toLowerCase() + "=") > -1 ){
                var aParam = aQueryString[iParam].split("=");
                strReturn = aParam[1];
                break;
            }
        }
    }
    return unescape(strReturn);
} 

function loadSelectOptions(elem, option_array){
   var x=document.getElementById(elem);

   for (i=0; i< option_array.length;i++){
      var y=document.createElement('option');
      y.text=option_array[i];
      x.add(y, null);
   }
}

function clearSelectOptions(elem){
    try {
        var x=document.getElementById(elem);
        var l=x.options.length;
        for (i=0;i<l;i++){
            x.remove(0);
        }
    }
    catch (err){
        //alert(err);
    }
}

function findSelectOptionIndex(elem, elem_value){
    var x=document.getElementById(elem);
    var l=x.options.length;
    var index = 0;
    for (i=0;i<l;i++){
        if (x.options[i].text == elem_value){
            index = i;
        }
    }
    return index;
}

function setSelectedOption(elem, option_index){
    var x=document.getElementById(elem);
    x.selectedIndex=option_index;
}

function wait(msec) {
    var date = new Date();
    var curDate = null;

    do { 
        curDate = new Date();
    }
    while(curDate - date < msec);
} 
/*
var taskManager = {
    queue : new Array(),    // Multidimensional array storing the various tasks and their states
    queueLength : 0,        // How many tasks are in the Queue (not run)?    
    isBusy: false,            // Is there a task currently running?
    runningTask : null,     // Which task is currently running?
    lastRunTask: null,      // What was the last run task?
    
    init : function (){
            this.currentTask = null;
            this.lastRunTask = null;
        },
    registerAsynchTask : function (function_pointer) {
            // Add the task to queue
            this.queue.push(function_pointer, "TO_DO")
            if (this.isBusy == false) {
                // Start the queued task
            }
        },
    runTask : function () {
            // Run the current task. Set the call back to register task completion.
        },
    callBack : function () {
            // This is the call back function to be passed to called functions (to alert when the asynch task completed
        }
}
*/